home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text.html;
-
- import java.awt.Rectangle;
- import javax.swing.text.AttributeSet;
- import javax.swing.text.html.HTML.Attribute;
-
- class Map$RectangleRegionContainment extends Rectangle implements Map.RegionContainment {
- float[] percents;
- int lastWidth;
- int lastHeight;
-
- public Map$RectangleRegionContainment(AttributeSet var1) {
- int[] var2 = Map.extractCoords(var1.getAttribute(Attribute.COORDS));
- this.percents = null;
- if (var2 != null && var2.length == 4) {
- super.x = var2[0];
- super.y = var2[1];
- super.width = var2[2];
- super.height = var2[3];
- if (super.x < 0 || super.y < 0 || super.width < 0 || super.height < 0) {
- this.percents = new float[4];
- this.lastWidth = this.lastHeight = -1;
-
- for(int var3 = 0; var3 < 4; ++var3) {
- if (var2[var3] < 0) {
- this.percents[var3] = (float)Math.abs(var2[var3]) / 100.0F;
- } else {
- this.percents[var3] = -1.0F;
- }
- }
- }
-
- } else {
- throw new RuntimeException("Unable to parse rectangular area");
- }
- }
-
- public boolean contains(int var1, int var2, int var3, int var4) {
- if (this.percents == null) {
- return ((Rectangle)this).contains(var1, var2);
- } else {
- if (this.lastWidth != var3 || this.lastHeight != var4) {
- this.lastWidth = var3;
- this.lastHeight = var4;
- if (this.percents[0] != -1.0F) {
- super.x = (int)(this.percents[0] * (float)var3);
- }
-
- if (this.percents[1] != -1.0F) {
- super.y = (int)(this.percents[1] * (float)var4);
- }
-
- if (this.percents[2] != -1.0F) {
- super.width = (int)(this.percents[2] * (float)var3);
- }
-
- if (this.percents[3] != -1.0F) {
- super.height = (int)(this.percents[3] * (float)var4);
- }
- }
-
- return ((Rectangle)this).contains(var1, var2);
- }
- }
- }
-